package com.deng.config;

import com.deng.template.HotsTemplate;
import com.deng.template.PostsTemplate;
import com.deng.template.TimeAgoMethod;
import com.jagregory.shiro.freemarker.ShiroTags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
@Configuration
public class FreemarkerConfig{
        @Autowired
        private freemarker.template.Configuration configuration;
        @Autowired
        PostsTemplate postsTemplate;
        @Autowired
        HotsTemplate hotsTemplate;
        @PostConstruct
        public void setUp() {
            configuration.setSharedVariable("timeAgo", new TimeAgoMethod());
            configuration.setSharedVariable("posts", postsTemplate);
            configuration.setSharedVariable("hots", hotsTemplate);
            configuration.setSharedVariable("shiro", new ShiroTags());
        }



}
